package com.haiermzj.client.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.haiermzj.client.R;


/**
 * Created by wanghaixin on 17/8/10.
 */
public class GeneralTopLayout extends LinearLayout {
    private final ImageView leftImg;
    private final View view;
    private ImageView rightImg;
    private TextView topTitle;

    public GeneralTopLayout(Context context) {
        this(context, null);
//        LayoutInflater.from(context).inflate(R.layout.general_top, this, true);

    }

    public GeneralTopLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
//        LayoutInflater.from(context).inflate(R.layout.general_top, this, true);

    }

    public GeneralTopLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        LayoutInflater.from(context).inflate(R.layout.general_top, this, true);
        view = findViewById(R.id.layout);
        topTitle = (TextView) findViewById(R.id.top_title);
        rightImg = (ImageView) findViewById(R.id.right_img);
        leftImg = (ImageView) findViewById(R.id.left_img);

    }


    public void setTitle(String title) {

        topTitle.setText(title);
    }


    public void setTitleColor(int res) {

        topTitle.setTextColor(res);
    }

    /*左边按钮 隐藏显示*/
    public void setLeftImgVisibale(int visibale) {

        leftImg.setVisibility(visibale);
    }

    /*右边按钮 隐藏显示*/
    public void setRightImgVisibale(int visibale) {

        rightImg.setVisibility(visibale);
    }


    /*左边按钮 监听点击事件*/
    public void setLeftImgOnClikListener(OnClickListener listener) {

        leftImg.setOnClickListener(listener);
    }

    /*扫码按钮 隐藏显示*/
    public void setRightImgOnClikListener(OnClickListener listener) {

        rightImg.setOnClickListener(listener);
    }  /*扫码按钮 隐藏显示*/

    public void setLeftImg(int res) {

        leftImg.setImageResource(res);
    }

    public void setRightlImg(int res) {

        rightImg.setImageResource(res);
    }

    public void setBackGroundf(int res) {

        view.setBackgroundColor(res);
    }

    public View getRightlView() {

        return rightImg;
    }


}

